<%@ Page Title="<%$ Concat:UIStrings.Applications,' &raquo; ResourceBlender.NET' %>" Language="C#" MasterPageFile="~/Layout.master" AutoEventWireup="true" CodeFile="Applications.aspx.cs" Inherits="Applications" EnableEventValidation="false" ValidateRequest="false" %>
<%@ MasterType VirtualPath="~/Layout.master" %>
<%@ Register Src="~/BundleEditor.ascx" TagPrefix="rb" TagName="BundleEditor" %>

<asp:Content ID="contentHead" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="contentMain" ContentPlaceHolderID="cntMain" Runat="Server">
    <asp:ScriptManager ID="scrBundles" runat="server">
        <Scripts>
            <asp:ScriptReference Path="~/js/applications.js" />
        </Scripts>
    </asp:ScriptManager>
    <asp:MultiView ID="mltMain" runat="server" ActiveViewIndex="1">
        <asp:View ID="viwManageApplications" runat="server">
            <h2><asp:Literal ID="lblManageApplications" runat="server" Text="<%$ Resources:UIStrings, ManageApplications %>"/></h2>
            <div class="breadcrumbs">
                <asp:HyperLink ID="lnkNavHome" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender.NET</asp:HyperLink> &gt; <asp:Literal runat="server" Text="<%$ Resources:UIStrings, Applications %>" />
            </div>
            <asp:ObjectDataSource ID="dsApplications" runat="server" TypeName="ResourceBlender.DAL.ResourceBlenderDAL" SelectMethod="GetApplications">
                <SelectParameters>
                    <asp:Parameter Name="includeBundles" Type="Boolean" DefaultValue="false" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <asp:GridView ID="grdApplications" runat="server" AllowPaging="True" 
                AllowSorting="False" AutoGenerateColumns="False" CssClass="nicetable" 
                DataSourceID="dsApplications" OnRowCommand="grdApplications_RowCommand" Width="100%">
                <PagerSettings PageButtonCount="7" />
                <Columns>
                    <asp:BoundField DataField="DisplayName" HeaderText="<%$ Resources:UIStrings, Application %>" 
                        SortExpression="displayname" />
                    <asp:TemplateField ItemStyle-CssClass="buttoncell" HeaderText="<%$ Resources:UIStrings, Edit %>">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnEdit" runat="server" 
                                ToolTip='<%# String.Format(Resources.UIStrings.EditName, Eval("DisplayName")) %>'
                                CommandArgument='<%# Eval("ID") %>' CommandName="doedit" 
                                ImageUrl="~/images/edit.png" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-CssClass="buttoncell" HeaderText="<%$ Resources:UIStrings, Delete %>">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnDelete" runat="server" 
                                ToolTip='<%# String.Format(Resources.UIStrings.DeleteName, Eval("DisplayName")) %>'
                                CommandArgument='<%# Eval("ID") %>' CommandName="confirmdelete" 
                                ImageUrl="~/images/delete.png" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle CssClass="excelHead" />
                <AlternatingRowStyle CssClass="alt" />
                <EmptyDataTemplate>
                    <p><asp:Literal runat="server" Text="<%$ Resources:UIStrings, NoApplicationsAdded %>" /></p>
                </EmptyDataTemplate>
            </asp:GridView>
            <asp:LinkButton ID="lnkAddApplication" runat="server" CssClass="lnkAdd" 
                OnClick="lnkAddApplication_Click" Text="<%$ Resources:UIStrings, AddApplication %>"></asp:LinkButton>
        </asp:View>
        <asp:View ID="pnlAddApplication" runat="server">
            <div class="niceform">
                <h2><asp:Literal ID="lblEditApplications" runat="server" Text="<%$ Resources:UIStrings, AddApplication %>" /></h2>
                <div class="breadcrumbs">
                    <asp:HyperLink ID="lnkNavAddHome" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender.NET</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavAddApplications" runat="server" NavigateUrl="~/Applications.aspx" Text="<%$ Resources:UIStrings, Applications %>"></asp:HyperLink> &gt; <asp:Literal runat="server" ID="litNavAddAddApplication" Text="<%$ Resources:UIStrings, AddApplication %>"></asp:Literal>
                </div>
                <fieldset>
                    <legend><asp:Literal runat="server" Text="<%$ Resources:UIStrings, ApplicationOptions %>" /></legend>
                    <div class="formrow block">
                        <asp:Label ID="lblAppName" runat="server" AssociatedControlID="txtAppName" 
                            Text="<%$ Resources:UIStrings, ApplicationName %>"></asp:Label>
                        <asp:TextBox ID="txtAppName" runat="server" ValidationGroup="addapplication"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="vldAppName" runat="server" 
                            ControlToValidate="txtAppName" Display="Dynamic" SetFocusOnError="true"
                            ErrorMessage="<%$ Resources:Errors, ApplicationNameRequired %>" ValidationGroup="addapplication"
                            CssClass="validationerror"></asp:RequiredFieldValidator>
                    </div>
                    <div class="formrow block">
                        <asp:Label ID="lblDisplayName" runat="server" AssociatedControlID="txtDisplayName" 
                            Text="<%$ Resources:UIStrings, DisplayName %>"></asp:Label>
                        <asp:TextBox ID="txtDisplayName" runat="server" ValidationGroup="addapplication"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="vldDisplayName" runat="server" 
                            ControlToValidate="txtDisplayName" Display="Dynamic" SetFocusOnError="true" ValidationGroup="addapplication"
                            ErrorMessage="<%$ Resources:Errors, DisplayNameRequired %>" CssClass="validationerror"></asp:RequiredFieldValidator>
                        <asp:Label ID="lblAppExists" runat="server" Visible="false"
                                Text="<%$ Resources:Errors, ApplicationExists %>" CssClass="block error" />  
                    </div>
                </fieldset>
                <fieldset>
                    <legend><asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:UIStrings, Languages %>" /></legend>
                    <asp:UpdatePanel ID="updLanguages" runat="server">
                        <ContentTemplate>
                            <div class="formrow block">
                                <div class="formcol">
                                    <asp:Label ID="lblLanguages" runat="server"
                                        AssociatedControlID="lstSelectedLangs" Text="<%$ Resources:UIStrings, SelectedLanguages %>"></asp:Label>
                                    <br />
                                    <asp:ListBox ID="lstSelectedLangs" runat="server" Width="20em" Rows="10" 
                                        CausesValidation="True" SelectionMode="Multiple" 
                                        ValidationGroup="vldLanguages"></asp:ListBox>
                                </div>
                                <div class="formcol" style="margin-top: 7em;">
                                    <asp:Button ID="btnAddLang" runat="server" Text="&lt;&lt;" 
                                        EnableViewState="False" CssClass="block" OnClick="btnAddLang_Click" />
                                    <asp:Button ID="btnRemoveLang" runat="server" Text="&gt;&gt;" 
                                        EnableViewState="False" CssClass="block" OnClick="btnRemoveLang_Click" />
                                </div>
                                <div class="formcol">
                                    <asp:Label ID="lblAvailableLanguages" runat="server" 
                                        AssociatedControlID="lstAvailableLangs" Text="<%$ Resources:UIStrings, AvailableLanguages %>"></asp:Label>
                                    <br />
                                    <asp:ListBox ID="lstAvailableLangs" runat="server" Width="20em" Rows="10" 
                                        SelectionMode="Multiple"></asp:ListBox>
                                </div>
                                <div class="clear"></div>
                                <div class="formrow block">
                                    <fieldset>
                                        <legend><asp:Literal ID="Literal2" runat="server" Text="<%$ Resources:UIStrings, AddCustomLanguage %>" /></legend>
                                        <asp:Label ID="lblAddCustomLanguageError" runat="server" Visible="false"
                                            CssClass="error block"></asp:Label>
                                        <asp:Label ID="lblCustomCode" runat="server" AssociatedControlID="txtCustomCode" 
                                            Text="<%$ Resources:UIStrings, LanguageCode %>"></asp:Label>
                                        <asp:TextBox ID="txtCustomCode" runat="server"></asp:TextBox>
                                        <asp:Button ID="btnCustomCode" runat="server"
                                            CssClass="uniformbutton btnAdd" EnableViewState="False" Text="<%$ Resources:UIStrings, AddLanguage %>" 
                                            CausesValidation="False" OnClick="btnAddCustomLanguage_Click" />
                                    </fieldset>
                                </div>
                                <asp:UpdateProgress ID="prgLanguages" runat="server" 
                                    AssociatedUpdatePanelID="updLanguages" 
                                    DisplayAfter="100">
                                    <ProgressTemplate>
                                        <div class="centered"><asp:Image ID="imgLoadingLanguages" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="<%$ Resources:UIStrings, Loading %>" /></div>
                                    </ProgressTemplate>
                                </asp:UpdateProgress>
                                <asp:CustomValidator ID="vldHasLanguages" runat="server" 
                                    ControlToValidate="lstSelectedLangs"  Display="Dynamic"
                                    ErrorMessage="<%$ Resources:Errors, OneLanguageSelectedRequired %>" 
                                    OnServerValidate="validateHasLanguages" ValidateEmptyText="True" 
                                    ValidationGroup="vldLanguages"></asp:CustomValidator>
                            </div>
                            <div class="formrow block">
                                <asp:Label ID="lblDefaultLanguage" runat="server" Text="<%$ Resources:UIStrings, DefaultLanguage %>"
                                    AssociatedControlID="cboDefaultLanguage"></asp:Label>
                                <asp:DropDownList ID="cboDefaultLanguage" runat="server">
                                </asp:DropDownList>
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </fieldset>
                <fieldset>
                    <legend><asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:UIStrings, Bundles %>" /></legend>
                    <asp:MultiView runat="server" ID="mltBundles">
                        <asp:View runat="server" ID="viwAddBundles">
                            <h3><asp:Literal ID="litExisting" runat="server" Text="<%$ Resources:UIStrings, ExistingBundles %>" /></h3>
                            <asp:UpdateProgress ID="prgUpdateBundles" runat="server" 
                                AssociatedUpdatePanelID="updBundles" DisplayAfter="100">
                                <ProgressTemplate>
                                    <div class="centered"><asp:Image ID="imgLoadingBundles" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="<%$ Resources:UIStrings, Loading %>" /></div>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                            <asp:UpdatePanel ID="updBundles" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <rb:BundleEditor ID="bundleEditor" runat="server" />
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </asp:View>
                        <asp:View runat="server" ID="viwEditBundles">
                            <div class="warningMessage">
                                <p><asp:Literal runat="server" Text="<%$ Resources:Errors, AppSaveRequiredToAddBundle %>" /></p>
                            </div>
                        </asp:View>
                    </asp:MultiView>
                    <%--asp:Label ID="lblNoBundles" runat="server" Visible="false"
                            Text="<%$ Resources:Errors, OneBundleRequired %>" CssClass="block error" /--%>
                </fieldset>
                <div class="formrow block actions">
                    <asp:Button ID="btnSave" runat="server" Text="<%$ Resources:UIStrings, Save %>" CssClass="uniformbutton btnSave" ValidationGroup="addapplication"
                        OnClick="btnSave_Click" />
                    <asp:Button ID="btnCancelAdd" runat="server"
                        CssClass="uniformbutton btnCancel" EnableViewState="False" Text="<%$ Resources:UIStrings, Cancel %>" 
                        OnClick="btnCancelDelete_Click" />
                </div>
            </div>
        </asp:View>
        <asp:View ID="pnlDeleteApplication" runat="server">
            <div class="breadcrumbs">
                <asp:HyperLink ID="lnkNavDeleteHome" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender.NET</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavDeleteApplications" runat="server" NavigateUrl="~/Applications.aspx" Text="<%$ Resources:UIStrings, Applications %>"></asp:HyperLink> &gt; <asp:Literal ID="Literal6" runat="server" Text="<%$ Resources:UIStrings, DeleteApplication %>" />
            </div>
            <div class="niceform confirmation">
                <h2><asp:Literal ID="lblConfirmDeletionHeading" runat="server" Text="<%$ Resources:UIStrings, ConfirmDeletion %>" EnableViewState="False" /></h2>
                <asp:Label ID="lblConfirmDelete" runat="server"></asp:Label>
                <br />
                <asp:Button ID="btnOk" runat="server" CommandName="confirmdelete" 
                    CssClass="uniformbutton btnConfirm" EnableViewState="False" onclick="btnOk_Click" 
                    Text="<%$ Resources:UIStrings, DeleteApplication %>" />
                <asp:Button ID="btnCancelDelete" runat="server" CommandName="canceldelete" 
                    CssClass="uniformbutton btnCancel" EnableViewState="False" Text="<%$ Resources:UIStrings, Cancel %>" 
                    OnClick="btnCancelDelete_Click" />
            </div>
        </asp:View>
        <asp:View ID="viwError" runat="server">
            <div class="niceform errorDiv">
                <h2><asp:Literal runat="server" Text="<%$ Resources:Errors, Error %>" /></h2>
                <p><asp:Literal ID="lblErrorDescription" runat="server" /></p>
            </div>
       </asp:View>
   </asp:MultiView>
</asp:Content>